/*
 * @Author: huangwei
 * @Date: 2021-04-19 10:31:47
 * @LastEditors: 黄威
 * @LastEditTime: 2021-09-08 15:38:36
 * @Description: lib打包模式下的配置文件，包含打包路径，和打包后的静态文件处理等
 */
const webpack = require('webpack')
const CopyPlugin = require('copy-webpack-plugin')
const nodeExternals = require('webpack-node-externals')

module.exports = {
    filenameHashing: false,
    productionSourceMap: false,
    // 需要合并的webpack配置
    configureWebpack: {
        // 默认暴露导出default
        output: {
            libraryExport: 'default',
        },
        plugins: [
            // 定义部分全局变量，打包时候会被替换
            new webpack.DefinePlugin({
                envIsDebug: false,
            }),
            // 复制配置文件到打包后目录
            new CopyPlugin([
                { from: 'package.json' },
                { from: './types', to: 'types' },
                // { from: './public/img', to: 'img' },
                { from: './src/styles', to: 'styles' },
            ]),
        ],
        // 打包要排除的文件（默认排除全部node_modules）
        // https://www.npmjs.com/package/webpack-node-externals
        // https://webpack.docschina.org/configuration/externals/#root
        externals: [nodeExternals(), /^cesium$/i],
    },
}
